<template>
    <div class="container-content">
        <!-- <el-row>
        <el-col :span="24">
            <h3 class="panel-title">新建客户</h3>
        </el-col>
    </el-row> -->
        <el-form
            ref="formObjectRef"
            :model="formObject"
            label-width="100px"
            :rules="rules"
            status-icon
            label-position="left"
        >
            <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
                <el-tab-pane label="供应商编码" name="code">
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item
                                label="创建组织"
                                prop="createDeptName"
                            >
                                <el-input
                                    v-model="formObject.createDeptName"
                                    disabled
                                >
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="使用组织" prop="useDeptName">
                                <el-input
                                    v-model="formObject.useDeptName"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="注册编码" prop="registerCode">
                                <el-input
                                    v-model="formObject.registerCode"
                                    disabled
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="编码" prop="supplierCode">
                                <el-input
                                    v-model="formObject.supplierCode"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="名称" prop="supplierName">
                                <el-input
                                    v-model="formObject.supplierName"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="简称" prop="forShort">
                                <el-input
                                    v-model="formObject.forShort"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
                <el-tab-pane label="基本信息" name="basic">
                    <div class="desc-title">地址</div>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="国家" prop="nationId">
                                <el-input
                                    v-model="formObject.nationId"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="地区" prop="countyId">
                                <el-input
                                    v-model="formObject.countyId"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="通讯地址"
                                prop="mailingAddress"
                            >
                                <el-input
                                    v-model="formObject.mailingAddress"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="邮政编码" prop="zipCode">
                                <el-input
                                    v-model="formObject.zipCode"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="语言" prop="language">
                                <el-input
                                    v-model="formObject.language"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="公司网址"
                                prop="companyWebsite"
                            >
                                <el-input
                                    v-model="formObject.companyWebsite"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <div class="desc-title">注册</div>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="行业" prop="industry">
                                <el-input
                                    v-model="formObject.industry"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="创立日期" prop="establishDate">
                                <el-date-picker
                                    v-model="formObject.establishDate"
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="法人代表"
                                prop="legalRepresentative"
                            >
                                <el-input
                                    v-model="formObject.legalRepresentative"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="注册资金"
                                prop="registeredCapital"
                            >
                                <el-input
                                    v-model="formObject.registeredCapital"
                                    placeholder="万元"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="工商登记号"
                                prop="registrationNumber"
                            >
                                <el-input
                                    v-model="formObject.registrationNumber"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="生产经营许可证"
                                prop="productionLicense"
                                label-width="120px"
                            >
                                <el-input
                                    v-model="formObject.productionLicense"
                                ></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col :span="8">
                            <el-form-item
                                label="注册地址"
                                prop="companyRegisteredAddress"
                            >
                                <el-input
                                    v-model="
                                        formObject.companyRegisteredAddress
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="统一社会信用代码"
                                prop="creditCode"
                                label-width="130px"
                            >
                                <el-input
                                    v-model="formObject.creditCode"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <div class="desc-title">管理</div>
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="负责部门" prop="chargeDept">
                                <el-input
                                    v-model="formObject.chargeDept"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="负责人" prop="chargePerson">
                                <el-input
                                    v-model="formObject.chargePerson"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="供应商分类"
                                prop="classification"
                            >
                                <el-input
                                    v-model="formObject.classification"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="供应类别"
                                prop="supplyCategory"
                            >
                                <el-input
                                    v-model="formObject.supplyCategory"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="供应商等级" prop="level">
                                <el-input v-model="formObject.level"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="供应商分组" prop="group">
                                <el-input v-model="formObject.group"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="公司类别"
                                prop="companyCategory"
                            >
                                <el-input
                                    v-model="formObject.companyCategory"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="公司性质" prop="companyNature">
                                <el-input
                                    v-model="formObject.companyNature"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="公司规模" prop="companySize">
                                <el-input
                                    v-model="formObject.companySize"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="对应组织"
                                prop="correspondingOrganization"
                            >
                                <el-input
                                    v-model="
                                        formObject.correspondingOrganization
                                    "
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item
                                label="对应集团供应商"
                                prop="groupSupplier"
                                label-width="140px"
                            >
                                <el-input
                                    v-model="formObject.groupSupplier"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
                <el-tab-pane label="联系人" name="more">
                    <el-table
                        :data="formObject.contracts"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <template #empty>
                            <el-button
                                plain
                                type="primary"
                                round
                                @click="addNewRow('contracts')"
                                >添加新行
                            </el-button>
                        </template>
                        <el-table-column label="操作" width="120">
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-plus"
                                    size="mini"
                                    @click="
                                        handleDataAdd(scope.$index, scope.row)
                                    "
                                ></el-button>
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete(
                                            scope.$index,
                                            scope.row,
                                            'contracts'
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column label="编码">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="code"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.code"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="联系人" width="150">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="name"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.name"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="性别">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="sex"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-select
                                        v-model="scope.row.sex"
                                        placeholder="请选择"
                                        style="width: 100%"
                                    >
                                        <el-option
                                            key="0"
                                            label="男"
                                            value="0"
                                        ></el-option>
                                        <el-option
                                            key="1"
                                            label="女"
                                            value="1"
                                        ></el-option>
                                        <el-option
                                            key="2"
                                            label="未知"
                                            value="2"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="职位">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="position"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.position"
                                    ></el-input>
                                    <!-- @change="
                                      positionChange(
                                          scope.row.position,
                                          scope.$index
                                      )
                                  " -->
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="电话">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="workTel"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.workTel"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="手机">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="mobile"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.mobile"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>

                        <el-table-column label="邮箱">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="email"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.email"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="传真">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="fax"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.fax"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="电子邮箱">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="email"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.email"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="默认联系人">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="isDefault"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-radio-group
                                        v-model="scope.row.isDefault"
                                    >
                                        <el-checkbox
                                            v-model="scope.row.isDefault"
                                        />
                                    </el-radio-group>
                                </el-form-item>
                            </template>
                        </el-table-column>

                        <el-table-column label="所属公司">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="belongCompany"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.belongCompany"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="详细地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="address"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.address"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="商务信息" name="business">
                    <el-row :gutter="20">
                        <el-col :span="6">
                            <el-form-item label="采购组" prop="purchaseGroup">
                                <el-input
                                    v-model="formObject.purchaseGroup"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item
                                label="默认价目表"
                                prop="defaultPriceList"
                            >
                                <el-input
                                    v-model="formObject.defaultPriceList"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="业务状态" prop="businessState">
                                <el-input
                                    v-model="formObject.businessState"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item
                                label="默认折扣表"
                                prop="defaultDiscount"
                            >
                                <el-input
                                    v-model="formObject.defaultDiscount"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="冻结范围" prop="freezeScope">
                                <el-input
                                    v-model="formObject.freezeScope"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="供货方" prop="supply">
                                <el-input
                                    v-model="formObject.supply"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="冻结人" prop="freezingPerson">
                                <el-input
                                    v-model="formObject.freezingPerson"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item
                                label="汇总公司"
                                prop="summaryCompany"
                            >
                                <el-input
                                    v-model="formObject.summaryCompany"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="冻结日期" prop="freezeDate">
                                <el-date-picker
                                    v-model="formObject.freezeDate"
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="保证金比例" prop="ensureRate">
                                <el-input
                                    v-model="formObject.ensureRate"
                                    placeholder="%"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item
                                label="默认联系人"
                                prop="defaultContracts"
                            >
                                <el-input
                                    v-model="formObject.defaultContracts"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="6">
                            <el-form-item label="VMI仓库" prop="vmiWarehouse">
                                <el-input
                                    :disabled="!formObject.isVmi"
                                    v-model="formObject.vmiWarehouse"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="VMI业务" prop="isVmi">
                                <el-checkbox v-model="formObject.isVmi" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item
                                label="启用供应商协同"
                                prop="enableCoordination"
                                label-width="110px"
                            >
                                <el-checkbox
                                    v-model="formObject.enableCoordination"
                                />
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
                <el-tab-pane label="财务信息" name="financial">
                    <el-row :gutter="20">
                        <el-col :span="6">
                            <el-form-item
                                label="对应客户"
                                prop="correspondingCustomer"
                            >
                                <el-input
                                    v-model="formObject.correspondingCustomer"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item
                                label="单次预付额度"
                                prop="singlePrepaymentLimit"
                            >
                                <el-input
                                    v-model="formObject.singlePrepaymentLimit"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="发票类型" prop="invoiceType">
                                <el-select
                                    v-model="formObject.invoiceType"
                                    filterable
                                    placeholder="请选择"
                                    style="width: 100%"
                                >
                                    <el-option
                                        v-for="item in invoiceTypeOptions"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="结算币别" prop="">
                                <!-- v-model="formObject.invoiceType" -->
                                <el-input></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="税分类" prop="taxType">
                                <el-input
                                    v-model="formObject.taxType"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="默认税率" prop="defaultTax">
                                <el-input
                                    v-model="formObject.defaultTax"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="结算方式" prop="balanceMethod">
                                <el-input
                                    v-model="formObject.balanceMethod"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="税务登记号" prop="taxNumber">
                                <el-input
                                    v-model="formObject.taxNumber"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="付款条件" prop="paymentTerms">
                                <el-input
                                    v-model="formObject.paymentTerms"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="经营类型" prop="manageType">
                                <el-input
                                    v-model="formObject.manageType"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="结算方" prop="balanceParty">
                                <el-input
                                    v-model="formObject.balanceParty"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="收款方" prop="payee">
                                <el-input v-model="formObject.payee"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
                            <el-form-item label="描述" prop="desc">
                                <el-input
                                    v-model="formObject.desc"
                                    type="textarea"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-table
                        :data="formObject.banks"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <template #empty>
                            <el-button
                                plain
                                type="primary"
                                round
                                @click="addNewRow('banks')"
                                >添加新行
                            </el-button>
                        </template>
                        <el-table-column label="操作" width="120">
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-plus"
                                    size="mini"
                                    @click="
                                        handleDataAdd_banks(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                ></el-button>
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete(
                                            scope.$index,
                                            scope.row,
                                            'banks'
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column label="开户国家">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="openingCountry"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.openingCountry"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="账户名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="accountName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.accountName"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <!--  -->
                        <el-table-column label="收款银行">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="dueBanke"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.dueBanke"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                                <!-- @change="
                                      positionChange(
                                          scope.row.position,
                                          scope.$index
                                      )
                                  " -->
                            </template>
                        </el-table-column>
                        <el-table-column label="网点名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="brancheName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.brancheName"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="银行网点">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="bankBranches"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.bankBranches"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>

                        <el-table-column label="开户行地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="openBankAddress"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.openBankAddress"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="开户银行">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="bankName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.bankName"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="银联号">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="unionPayAccount"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.unionPayAccount"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>

                        <el-table-column label="币别">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="currency"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.currency"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="默认">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="isDefault"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-radio-group
                                        v-model="scope.row.isDefault"
                                    >
                                        <el-checkbox
                                            v-model="scope.row.isDefault"
                                        />
                                    </el-radio-group>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="描述">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="desc"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.desc"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="组织信息" name="org">
                    <el-table
                        :data="formObject.organizations"
                        style="width: 100%"
                        highlight-current-row
                        border
                    >
                        <template #empty>
                            <el-button
                                plain
                                type="primary"
                                round
                                @click="addNewRow('org')"
                                >添加新行
                            </el-button>
                        </template>
                        <el-table-column label="操作" width="120">
                            <template slot-scope="scope">
                                <el-button
                                    plain
                                    icon="el-icon-plus"
                                    size="mini"
                                    @click="
                                        handleDataAdd_org(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                ></el-button>
                                <el-button
                                    plain
                                    icon="el-icon-minus"
                                    size="mini"
                                    @click="
                                        handleDataDelete(
                                            scope.$index,
                                            scope.row,
                                            'org'
                                        )
                                    "
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column label="编码">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="locationCode"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.locationCode"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="地点名称">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="locationName"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.locationName"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="通讯地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="mailingAddress"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.mailingAddress"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="启用">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="isEnable"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-radio-group
                                        v-model="scope.row.isEnable"
                                    >
                                        <el-checkbox
                                            v-model="scope.row.isEnable"
                                        />
                                    </el-radio-group>
                                </el-form-item>
                            </template>
                        </el-table-column>

                        <el-table-column label="电话">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="workTel"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.workTel"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="手机">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="mobile"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.mobile"
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="传真">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="fax"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.fax"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="电子邮箱">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="email"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.email"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>

                        <el-table-column label="备注">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="remark"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-input
                                        v-model="scope.row.remark"
                                        clearable
                                    ></el-input>
                                </el-form-item>
                            </template>
                        </el-table-column>

                        <el-table-column label="默认供货地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="isDefaultSupply"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-radio-group
                                        v-model="scope.row.isDefaultSupply"
                                    >
                                        <el-checkbox
                                            v-model="scope.row.isDefaultSupply"
                                        />
                                    </el-radio-group>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="默认开票地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="isDefaultInvoicing"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-radio-group
                                        v-model="scope.row.isDefaultInvoicing"
                                    >
                                        <el-checkbox
                                            v-model="
                                                scope.row.isDefaultInvoicing
                                            "
                                        />
                                    </el-radio-group>
                                </el-form-item>
                            </template>
                        </el-table-column>
                        <el-table-column label="默认收款地址">
                            <template slot-scope="scope">
                                <el-form-item
                                    prop="isDefaultPayment"
                                    label-width="0px"
                                    style="margin: 0"
                                >
                                    <el-radio-group
                                        v-model="scope.row.isDefaultPayment"
                                    >
                                        <el-checkbox
                                            v-model="scope.row.isDefaultPayment"
                                        />
                                    </el-radio-group>
                                </el-form-item>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="其他信息" name="other">
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="创建人" prop="userId">
                                <el-input
                                    v-model="formObject.userId"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="审核人" prop="examineId">
                                <el-input
                                    v-model="formObject.examineId"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="禁用人" prop="disabledId">
                                <el-input
                                    v-model="formObject.disabledId"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="创建日期" prop="establishDate">
                                <el-date-picker
                                    v-model="formObject.establishDate"
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="审核日期" prop="examineTime">
                                <el-date-picker
                                    v-model="formObject.examineTime"
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="禁用日期" prop="disabledDate">
                                <el-date-picker
                                    v-model="formObject.disabledDate"
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="修改人" prop="changeId">
                                <el-input
                                    v-model="formObject.changeId"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="数据状态" prop="dataState">
                                <el-input
                                    v-model="formObject.dataState"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="禁用状态" prop="disabledState">
                                <el-input
                                    v-model="formObject.disabledState"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="修改日期" prop="changeTime">
                                <el-date-picker
                                    v-model="formObject.changeTime"
                                    type="date"
                                    placeholder="选择日期"
                                    style="width: 100%"
                                >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-tab-pane>
            </el-tabs>
            <!-- <el-form-item label-width="0px" style="margin-top: 20px">
            <el-button
                type="primary"
                size="medium"
                @click="formSubmit('basicFormRef')"
            >保存
            </el-button
            >
            <el-button size="medium" @click="formRest('basicFormRef')"
            >取消
            </el-button
            >
        </el-form-item> -->
        </el-form>
        <!-- 创建组织 -->
        <el-dialog
            title="组织机构列表"
            :visible.sync="showOrg"
            append-to-body
            width="70%"
        >
            <el-table
                ref="orgTable"
                :data="orgData"
                @selection-change="selectOrgItem"
            >
                <el-table-column type="selection" width="55" align="center">
                </el-table-column>
                <el-table-column
                    property="deptName"
                    label="名称"
                ></el-table-column>
                <el-table-column property="name" label="形态"></el-table-column>
                <el-table-column
                    property="address"
                    label="核算组织"
                ></el-table-column>
                <el-table-column
                    property="address"
                    label="核算组织类型"
                ></el-table-column>
                <el-table-column
                    property="address"
                    label="所属法人"
                ></el-table-column>
                <el-table-column
                    property="address"
                    label="业务组织"
                ></el-table-column>
                <el-table-column
                    property="address"
                    label="数据状态"
                ></el-table-column>
            </el-table>
            <el-pagination
                class="pagination"
                background
                layout="total, sizes, prev, pager, next, jumper"
                :total="orgTotal"
            >
            </el-pagination>
        </el-dialog>
    </div>
</template>
<script>
import { listDept } from "@/api/system/dept";
import { getAreaList } from "@/api/area/area";
import { add } from "@/api/base/data";
import { getInfo } from "@/api/login";
import { updataSupplierList,editSupplierList } from "@/api/bim/outher";
export default {
     props: ["id"],
    data() {
        return {
            flag:false,
            activeName: "code",
            showOrg: false,
            formObjectRef:'',
            counties: [],
            orgData: [], //创建组织弹窗列表
            orgSelect: [], //选中项
            orgTotal: "", //创建组织弹窗分页
            formObject: {
                balanceCurrency: "",
                balanceMethod: "",
                balanceParty: "",
                banks: [],
                businessState: "",
                changeId: "",
                changeTime: "",
                chargeDept: "",
                chargePerson: "",
                cityId: "",
                classification: "",
                companyCategory: "",
                companyNature: "",
                companyRegisteredAddress: "",
                companySize: "",
                companyWebsite: "",
                contracts: [],
                correspondingCustomer: "",
                correspondingOrganization: "",
                countyId: "",
                createDept: "",
                createDeptName: "",
                createTime: "",
                creditCode: "",
                dataState: "",
                defaultContracts: "",
                defaultDiscount: "",
                defaultPriceList: "",
                defaultTax: "",
                desc: "",
                disabledDate: "",
                disabledId: "",
                disabledState: "",
                enableCoordination: false,
                ensureRate: "",
                establishDate: "",
                examineId: "",
                examineTime: "",
                forShort: "",
                freezeDate: "",
                freezeScope: "",
                freezingPerson: "",
                group: "",
                groupSupplier: "",
                id: "",
                industry: "",
                invoiceType: "",
                isVmi: false,
                language: "",
                legalRepresentative: "",
                level: "",
                mailingAddress: "",
                manageType: "",
                nationId: "",
                organizations: [],
                payee: "",
                paymentTerms: "",
                productionLicense: "",
                provincesId: "",
                purchaseGroup: "",
                registerCode: "",
                registeredCapital: "",
                registrationNumber: "",
                singlePrepaymentLimit: "",
                summaryCompany: "",
                supplierCode: "",
                supplierName: "",
                supply: "",
                supplyCategory: "",
                taxNumber: "",
                taxType: "",
                useDept: "",
                useDeptName: "",
                userId: "",
                vmiWarehouse: "",
                zipCode: "",
            },
            invoiceTypeOptions: [
                {
                    value: "1",
                    label: "增值说专业用票",
                },
                {
                    value: "2",
                    label: "普通发票",
                },
            ],
            rules: {
                createDeptName: [
                    { required: true, message: "", trigger: "blur" },
                ],
                useDeptName: [
                    {
                        required: true,
                        message: "",
                        trigger: "blur",
                    },
                ],
                supplierName: [
                    {
                        required: true,
                        message: "请输入名称！",
                        trigger: "blur",
                    },
                ],
            },
        };
    },
    methods: {
        // 页签切换事件
        handleClick(tab, event) {
            console.log(tab, event);
        },
        // 附件上传
        handleFileChange() {
            console.log("文件上传");
        },

        // 基础表单提交
        submitForm(cb) {
            if (this.flag) {
                // this.$refs[formObjectRef].validate((valid) => {
                // if (!valid) {
                //     this.$message.error("请完善表单信息！");
                //     return;
                // }

                editSupplierList(this.formObject, "Supplier").then((res) => {
                    if (res.code === 200) {
                        cb();
                        this.$message({
                            message: "修改成功！",
                            type: "success",
                        });
                        this.flag=false
                    }
                });
            // });
            }else{
                // this.$refs[formObjectRef].validate((valid) => {
                // if (!valid) {
                //     this.$message.error("请完善表单信息！");
                //     return;
                // }

                add(this.formObject, "Supplier").then((res) => {
                    if (res.code === 200) {
                        cb();
                        this.$message({
                            message: "新增成功！",
                            type: "success",
                        });
                    }
                });
            // });
            }
        },
        // 基础表单取消
        formRest(basicFormRef) {
            this.$refs[basicFormRef].resetFields();
        },
        // 联系人表单 添加行
        handleDataAdd() {
            if (this.formObject.contracts == undefined) {
                this.formObject.contracts = [];
            }
            let obj = {};

            obj.address = "";
            obj.addressCode = "";
            obj.addressName = "";
            obj.belongCompany = "";
            obj.facsimile = "";
            obj.email = "";
            obj.fax = "";
            obj.mobile = "";
            obj.name = "";
            obj.position = "";
            obj.isDefault = "";
            obj.company = "";
            obj.sex = "";
            obj.workTel = "";
            obj.supplierId = "";
            this.formObject.contracts.push(obj);
        },
        // 删除行
        handleDataDelete(index, row, type) {
            this.$confirm("请确认是否要删除此行？", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
                    this.$message({
                        type: "success",
                        message: "删除成功!",
                    });
                    if (type == "org") {
                        this.formObject.organizations.splice(index, 1);
                    } else if (type == "banks") {
                        this.formObject.banks.splice(index, 1);
                    } else {
                        this.formObject.contracts.splice(index, 1);
                    }
                })
                .catch(() => {
                    this.$message({
                        type: "info",
                        message: "已取消删除",
                    });
                });
        },
        //银行信息表单 添加行
        handleDataAdd_banks() {
            if (this.formObject.banks == undefined) {
                this.formObject.banks = [];
            }
            let obj = {};
            obj.openingCountry = "";
            obj.bankAccount = "";
            obj.accountName = "";
            obj.dueBanke = "";
            obj.brancheName = "";
            obj.bankBranches = "";
            obj.openBankAddress = "";
            obj.bankName = "";
            obj.unionPayAccount = "";
            obj.currency = "";
            obj.isDefault = "";
            this.formObject.banks.push(obj);
        },

        //组织表单 添加行
        handleDataAdd_org() {
            if (this.formObject.organizations == undefined) {
                this.formObject.organizations = [];
            }
            let obj = {};
            obj.isDefaultInvoicing = "";
            obj.isDefaultPayment = "";
            obj.isDefaultSupply = "";
            obj.isEnable = "";
            obj.locationCode = "";
            obj.locationName = "";
            obj.tel = "";
            obj.email = "";
            obj.fax = "";
            obj.mailingAddress = "";
            obj.remark = "";
            obj.supplierId = "";
            obj.isUsed = "";
            this.formObject.organizations.push(obj);
        },

        //添加新行
        addNewRow(type) {
            if (type === "org") {
                this.handleDataAdd_org();
            } else if (type === "bank") {
                this.handleDataAdd_bank();
            } else {
                this.handleDataAdd();
            }
        },
        //默认获取省列表
        getProvince(parentId) {
            // 查询省份
            getAreaList({ parentId: parentId }).then((res) => {
                this.provinces = res.rows;
            });
        },
        //点击省份获取城市列表
        getCity(parentId) {
            this.formObject.cityId = "";
            this.formObject.countyId = "";
            this.counties = [];
            // 查询省份
            getAreaList({ parentId: parentId }).then((res) => {
                this.cities = res.rows;
            });
        },
        //点击城市获取区县列表
        getCounty(parentId) {
            this.formObject.countyId = "";
            // 查询省份
            getAreaList({ parentId: parentId }).then((res) => {
                this.counties = res.rows;
            });
        },
        // 创建组织
        selectOrg() {
            this.showOrg = true;
            let level = 1;
            listDept({ level }).then((res) => {
                if (res.code === 200) {
                    this.orgData = res.data;
                }
                return;
            });
        },
        // 创建组织item
        selectOrgItem(val) {
            if (val.length === 1) {
                this.orgSelect = val;
                this.showOrg = false;
            }
        },
    },
    created() {
        // this.$refs["formObjectRef"].resetFields();
        if (this.id!='') {
            updataSupplierList(this.id).then((res)=>{
                this.formObject=res.data
                this.flag=true
            })
        }
        // 查询中国下属省份
        this.getProvince("20230705392153575054249984");

        getInfo().then((res) => {
            // 创建组织
            this.formObject.createDept = res.deptId;
            this.formObject.createDeptName = res.deptName;
            // 使用组织
            this.formObject.useDept = res.deptId;
            this.formObject.useDeptName = res.deptName;
        });
    },
};
</script>
<style lang="scss" scoped>
// .add {
//   padding: 15px;
// }
.panel-title {
    font-size: 18px;
    color: #37474f;
    font-weight: 500;
    text-shadow: rgba(0, 0, 0, 0.15) 0 0 1px;
}

::v-deep .el-form-item__content {
    margin-left: 0;
}

.main-responsible {
    font-size: 14px;
    font-weight: 550;
    color: #263238;
    position: relative;
    text-indent: 15px;
}
</style>
